package ch.bfh.ti.pixelator;

import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.support.v13.app.FragmentPagerAdapter;
import ch.bfh.ti.pixelator.camera.ReceiveFragment;
import ch.bfh.ti.pixelator.preferences.MainPreferenceFragment;
import ch.bfh.ti.pixelator.send.SendFragment;

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {
	private SendFragment sendFragment;
	private ReceiveFragment receiveFragment;
	private MainPreferenceFragment settingsFragment;
	private ShareFragment shareFragment;
	
	public SectionsPagerAdapter(FragmentManager fm, Context c) {
		super(fm);
		sendFragment = new SendFragment();
		receiveFragment = new ReceiveFragment();
		settingsFragment = new MainPreferenceFragment();
		shareFragment = new ShareFragment();
	}
	
	public SendFragment getSendFragment() {
		return sendFragment;
	}
	
	public ReceiveFragment getReceiveFragment() {
		return receiveFragment;
	}

	@Override
	public Fragment getItem(int position) {
		switch (position) {
		case 0:
			return sendFragment;
		case 1:
			return receiveFragment;
		case 2:
			return settingsFragment;
		case 3:
			return shareFragment;
		}
		
		throw new IllegalArgumentException();
	}

	@Override
	public int getCount() {
		return 4;
	}

	public int getIcon(int position) {
		switch (position) {
		case 0:
			return R.drawable.send;
		case 1:
			return R.drawable.receive;
		case 2:
			return R.drawable.settings;
		case 3:
			return R.drawable.share;
		}
		return 0;
	}
}